<%-- 
    Document   : newtest
    Created on : 03/09/2010, 10:09:05 AM
    Author     : Crespo
--%>

<%@page import="java.util.HashMap"%>
<%@page import="java.lang.Integer"%>
<%@page import="java.util.ArrayList"%>
<%@page import="niseeEntity.NiseeUser"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    ArrayList<Integer> image_ids =( ArrayList<Integer> )session.getAttribute("image_ids");
    HashMap<Integer,String> id_answer = (HashMap<Integer,String>)session.getAttribute("map");
    Integer counter = (Integer) session.getAttribute("counter");
    System.out.println("total images: " + image_ids.size() + " current: " + counter);
    String answer = request.getParameter("answer");
    int image_id = -1;
    if(counter > 0){
     
          image_id = image_ids.get(counter - 1);
             System.out.println("image:" + image_id+ "answer:" + answer);

        id_answer.put(new Integer(image_id), answer);
    }
    if(counter < image_ids.size()){
        image_id = image_ids.get(counter);
        counter++;
        session.setAttribute("map", id_answer);
        session.setAttribute("counter", counter);
    }else{
            image_id = -1;
            String finish = "finishTest";
            RequestDispatcher dispatch = request.getRequestDispatcher(finish);
            dispatch.forward(request, response);
    }
   

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
           <link rel="stylesheet" href="niseecss.css" type="text/css" media="screen" />
        <title>Test</title>
    </head>
    <body>
         <table>
             <tr><td colspan="2">
        <img alt="" height="300" width="300"  src="getImage?id=<%=image_id%>" />
                 </td></tr>
             <tr>
        <form action="newtest.jsp" method="POST" >
            <td><input type="text" name="answer" value=""  /></td>
            <td> <input type="image" src="images/next.png" value="Next" /></td>
            
        </form>
         </tr>
         </table>
    </body>
</html>
